package com.job.controller;

import com.job.pojo.Check;
import com.job.pojo.Money;
import com.job.service.CheckService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;

@Controller
@RequestMapping("/check")
public class CheckController {

    //创建服务层对象实例
    @Autowired
    CheckService checkService;




    //处理查询所有考勤记录的ajax请求
    @RequestMapping("/selectAllAjax")
    @ResponseBody
    public HashMap<String, Object> selectAll(Check check)
    {

        return checkService.selectAll(check);
    }

    //处理按用户名查询考勤数据的ajax请求
    @RequestMapping("/selectByNameAjax")
    @ResponseBody
    public HashMap<String,Object>selectByName(Check check)
    {
        return checkService.selectByName(check);
    }

    //处理申请的ajax
    @RequestMapping("/applyAjax")
    @ResponseBody
    public HashMap<String,Object> apply(Check check)
    {
        HashMap<String,Object> map = new HashMap<String,Object>();
       String info=checkService.apply(check);
        map.put("info",info);
        return map;
    }


    //查询时间
    @RequestMapping("/time")
    @ResponseBody
    public List<Check> time(){
        return checkService.selectTime();
    }


    //处理饼图的ajax数据
    @RequestMapping("/bingAjax")
    @ResponseBody
    public HashMap<String,Object> bingAjax(Check check){
        return checkService.bing(check);

    }

    //处理查询工资的ajax

    @RequestMapping("/selectMoneyAjax")
    @ResponseBody
    public HashMap<String,Object> selectMoney(Money money){
        return checkService.selectMoney(money);

    }
    @RequestMapping("/selectAllMoneyAjax")
    @ResponseBody
    public HashMap<String,Object> selectAllMoney(Money money){
        return checkService.selectAllMoney(money);

    }


    //处理修改工资的ajax
    @RequestMapping("/updateMoneyAjax")
    @ResponseBody
    public HashMap<String,Object> updateMoney(Money money)
    {
        HashMap<String,Object> map = new HashMap<String,Object>();
        String info=checkService.updateMoney(money);
        map.put("info",info);
        return map;
    }


    //ajax
    @RequestMapping("/countAjax")
    @ResponseBody
    public HashMap<String,Object> count(Money money)
    {
        HashMap<String,Object> map = checkService.count(money);

        return map;
    }

    //处理删除的ajax
    @RequestMapping("/delUserAjax")
    @ResponseBody
    public HashMap<String,Object>delUser(Money money)
    {
        HashMap<String,Object> map =new HashMap<>();
        String info=checkService.delUser(money);
        map.put("info",info);
        return map;
    }

    //处理增加的ajax
    @RequestMapping("/addAjax")
    @ResponseBody
    public HashMap<String,Object>add(Money money)
    {
        HashMap<String,Object> map =new HashMap<>();
        String info=checkService.add(money);
        map.put("info",info);
        return map;
    }

}
